//
//  MtViewController.m
//  豆瓣2
//
//  Created by dllo on 15/12/19.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "MtViewController.h"
#import "landView.h"
#import "logonViewController.h"
@interface MtViewController ()<landViewDelegate,UITextFieldDelegate>


@property (nonatomic,retain)landView *myView;
@end

@implementation MtViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.myView = [[landView alloc]initWithFrame:self.view.bounds];
    self.myView.backgroundColor = [UIColor lightGrayColor];
    self.myView.myDelegate = self;
    [self.view addSubview:self.myView];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(Actionbutton:)];
}

- (void)Actionbutton:(UIBarButtonItem *)bnt{
    
    
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
}

-(void)showOne{
    NSString *name = [[NSUserDefaults standardUserDefaults]objectForKey:@"name"];
    NSString *pass = [[NSUserDefaults standardUserDefaults]objectForKey:@"pass"];
    
    NSLog(@"-----%@",name);
    
    if (self.myView.afield.text == name&& self.myView.bfield.text == pass) {
       
        UIAlertController *aler = [UIAlertController alertControllerWithTitle:@"提示" message:@"登陆成功" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:aler animated:YES completion:^{
            [[NSUserDefaults standardUserDefaults]setObject:@"no" forKey:@"bool"];

        }];
        
        UIAlertAction *a = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
            [self dismissViewControllerAnimated:YES completion:^{
                
                
            }];

            
        }];
        [aler addAction:a];

       
    }if (self.myView.afield.text.length <=0||self.myView.bfield.text.length<=0) {
        
        UIAlertController *aler = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码账号不能为空" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:aler animated:YES completion:^{
            
        }];
        
        UIAlertAction *a = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        [aler addAction:a];
    }else{
        
        UIAlertController *aler = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码错误" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:aler animated:YES completion:^{
            
        }];
        
        UIAlertAction *a = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        [aler addAction:a];
        
    }

    
    
    
}

-(void)show{
    NSLog(@"aa");
    logonViewController *log = [[logonViewController alloc]init];
    
    [self.navigationController pushViewController:log animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
